Skip to content

Implement configurable color palette system#458

Merged
ocots merged 4 commits into
mainfrom
feat/configurable-color-palette
Jun 22, 2026
Merged

Implement configurable color palette system#458
ocots merged 4 commits into
mainfrom
feat/configurable-color-palette

Conversation

@ocots

@ocots ocots commented Jun 22, 2026

Copy link
Copy Markdown
Member

This PR introduces a flexible color palette system that allows users to customize terminal output colors through semantic roles.

Summary

  • New types: Style (ANSI code wrapper) and Palette (complete set of display styles)
  • Built-in palettes:
    • DEFAULT_PALETTE - standard colors mirroring Julia REPL conventions
    • MONOCHROME_PALETTE - no styling for CI/logs
    • HIGH_CONTRAST_PALETTE - bright bold variants for accessibility
  • Runtime API:
    • set_palette!(p) - switch active palette globally
    • reset_palette!() - restore default
    • set_color!(role, code) - fine-grained customization of single semantic role
    • current_palette() - query active palette
    • show_palette() - visual preview of active palette
  • Integration: All display paths (show, describe, exceptions, TestRunner) now read from the active palette
  • Documentation: New guide page docs/src/guide/color-system.md with examples
  • Tests: Comprehensive test suite in test/suite/core/test_palette.jl

Semantic roles

The palette defines 11 semantic roles: name, type, value, keyword, count, label, emphasis, muted, error, warning, success. Each maps to a specific ANSI code and governs how different categories of information are rendered.

Example usage

using CTBase

# Switch to high contrast
CTBase.Core.set_palette!(CTBase.Core.HIGH_CONTRAST_PALETTE)

# Customize a single role
CTBase.Core.set_color!(:error, "35")  # magenta errors

# Preview the active palette
CTBase.Core.show_palette()

# Reset to default
CTBase.Core.reset_palette!()

Breaking changes

None. This is a pure addition with no changes to existing behavior (default palette matches previous hardcoded colors).

Add a flexible color palette system allowing users to customize terminal output colors through semantic roles. Features include:

- New Style and Palette types for ANSI color management
- Three built-in palettes: DEFAULT, MONOCHROME, and HIGH_CONTRAST
- Runtime palette switching via set_palette!() and reset_palette!()
- Fine-grained color customization with set_color!()
- Visual palette preview with show_palette()
- Updated all display paths to use the active palette
- Comprehensive test coverage and documentation
ocots added 3 commits June 22, 2026 16:33
- Remove DocStringExtensions dependency (use TYPEDEF/TYPEDSIGNATURES directly)
- Split code into separate files: page_building.jl, config_helpers.jl
- Remove 'See also' references from internal helper docstrings
- Update Project.toml extension dependencies
- Documentation build now succeeds with updated structure
- Remove custom HTML anchor generation (_heading_anchor function)
- Use simple text labels [Module], [Function], etc. instead of anchors
- Add titlecase for doc type labels
- Generated API pages now in docs/src/api/
@ocots
ocots merged commit 024b551 into main Jun 22, 2026
4 checks passed
@ocots
ocots deleted the feat/configurable-color-palette branch June 22, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant